package Gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;

public class GuiListener implements ActionListener, MouseListener{

	private Gui g;

	public GuiListener(Gui g){
		this.g = g;
	}

	/**
	 * Dies ist der ActionListener
	 */
	public void actionPerformed(ActionEvent ae) {
		if(ae.getSource().equals(g.getAnzeigen())){
			g.setZeiten(g.getDropdownmit().getSelectedItem(), g.getDropdowndat().getSelectedItem());
			g.setStatus();
		}
		else if(ae.getSource().equals(g.getAktualisieren())){
			try {
				g.getGlo().synchronizeData();
			} catch (IOException e) {
				e.printStackTrace();
			}
			try {
				g.getGlo().synchronizeUsers();
			} catch (IOException e) {
				e.printStackTrace();
			}
			g.setZeiten(g.getDropdownmit().getSelectedItem(), g.getDropdowndat().getSelectedItem());
			g.setStatus();
		}
	}

	@Override
	public void mouseClicked(MouseEvent arg0) {
		g.setImage();
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub	
	}
}